angular.module('mamApp').controller('testController', ['$scope', '$state','$log','ImsDialog','paramsManager','ImsAlert','userValidate', function ($scope, $state,$log,ImsDialog,paramsManager,ImsAlert,userValidate) {
  console.log(paramsManager.params([1,2,3,4,5]))
  console.log(paramsManager.query({a:1,b:2,c:3}))
$scope.userValidate=userValidate;
  console.log(userValidate)
  $scope.rangeDate = {
    startDate:moment().startOf('day').add(-29, 'days').format('X'),
    endDate: moment().endOf('day').add(0, 'days').format('X'),
    onSelected: function (data, scope) {  //时间选择确认事件
     console.log(data)
    }
  };
  $scope.minDate = new Date();
 
  $scope.country = {};
  $scope.countries = [ // Taken from https://gist.github.com/unceus/6501985

    {name: 'Chad', code: 'TD'},
    {name: 'Chile', code: 'CL'},
    {name: 'China', code: 'CN'},
    {name: 'Christmas Island', code: 'CX'},
    {name: 'Cocos (Keeling) Islands', code: 'CC'},
    {name: 'Colombia', code: 'CO'},
    {name: 'Comoros', code: 'KM'},
    {name: 'Congo', code: 'CG'},
    {name: 'Congo, The Democratic Republic of the', code: 'CD'},
    {name: 'Cook Islands', code: 'CK'},
    {name: 'Costa Rica', code: 'CR'},
    {name: 'Cote D\'Ivoire', code: 'CI'},
    {name: 'Croatia', code: 'HR'},
    {name: 'Cuba', code: 'CU'},
    {name: 'Cyprus', code: 'CY'},
    {name: 'Czech Republic', code: 'CZ'},
    {name: 'Denmark', code: 'DK'},
    {name: 'Djibouti', code: 'DJ'},
    {name: 'Dominica', code: 'DM'},
    {name: 'Dominican Republic', code: 'DO'},
    {name: 'Ecuador', code: 'EC'},
    {name: 'Egypt', code: 'EG'},
    {name: 'El Salvador', code: 'SV'},
    {name: 'Equatorial Guinea', code: 'GQ'},
    {name: 'Eritrea', code: 'ER'},
    {name: 'Estonia', code: 'EE'},
    {name: 'Ethiopia', code: 'ET'},
    {name: 'Falkland Islands (Malvinas)', code: 'FK'},
    {name: 'Faroe Islands', code: 'FO'},
    {name: 'Fiji', code: 'FJ'},
    {name: 'Finland', code: 'FI'},
    {name: 'France', code: 'FR'},
    {name: 'French Guiana', code: 'GF'},
    {name: 'French Polynesia', code: 'PF'}
  ];
/*  $scope.myImage='';
  $scope.myCroppedImage='';

  var handleFileSelect=function(evt) {
    var file=evt.currentTarget.files[0];
    var reader = new FileReader();
    reader.onload = function (evt) {
      $scope.$apply(function($scope){
        $scope.myImage=evt.target.result;
      });
    };
    reader.readAsDataURL(file);
  };
  angular.element(document.querySelector('#fileInput')).on('change',handleFileSelect);*/
 /* $scope.popup2={};
  $scope.open2 = function() {
    $scope.popup2.opened = true;
  };
  $scope.items = ['item1', 'item2', 'item3'];

  $scope.animationsEnabled = true;*/

  $scope.open = function (size) {
    ImsDialog.open({title:"删除确认",message:"您确定要删除该条数据吗?"}).then(function (a) {
      console.log(a)
    })
  };
  $scope.open1 = function (size) {
    ImsDialog.open({title:"封禁确认",message:"您已经将<span style='color: #ed5b5e'>XXXXX</span>封禁?",rightBtn:"去封禁列表查看",rightBtnStyle:'background-color:#4fc3ba'}).then(function (a) {
      console.log(a)
    })
  };
  $scope.open2 = function (size) {
    ImsAlert.open({message:"密码修改成功"}).then(function (a) {
      console.log(a)
    })
  };

  $scope.toggleAnimation = function () {
    $scope.animationsEnabled = !$scope.animationsEnabled;
  };
  
  
  $scope.chartOpt1 = {
    title: {
      text: '折线图堆叠'
    },
    tooltip: {
      trigger: 'axis'
    },
    legend: {
      data:['邮件营销','联盟广告','视频广告','直接访问','搜索引擎']
    },
    grid: {
      left: '3%',
      right: '4%',
      bottom: '3%',
      containLabel: true
    },
    toolbox: {
      feature: {
        saveAsImage: {}
      }
    },
    xAxis: {
      type: 'category',
      boundaryGap: false,
      data: ['周一','周二','周三','周四','周五','周六','周日']
    },
    yAxis: {
      type: 'value'
    },
    series: [
      {
        name:'邮件营销',
        type:'line',
        stack: '总量',
        data:[120, 132, 101, 134, 90, 230, 210]
      },
      {
        name:'联盟广告',
        type:'line',
        stack: '总量',
        data:[220, 182, 191, 234, 290, 330, 310]
      },
      {
        name:'视频广告',
        type:'line',
        stack: '总量',
        data:[150, 232, 201, 154, 190, 330, 410]
      },
      {
        name:'直接访问',
        type:'line',
        stack: '总量',
        data:[320, 332, 301, 334, 390, 330, 320]
      },
      {
        name:'搜索引擎',
        type:'line',
        stack: '总量',
        data:[820, 932, 901, 934, 1290, 1330, 1320]
      }
    ]
  };
 $scope.chartOpt2 = {
   title: {
     text: '一天用电量分布',
     subtext: '纯属虚构'
   },
   tooltip: {
     trigger: 'axis'
   },
   toolbox: {
     show: true,
     feature: {
       saveAsImage: {}
     }
   },
   xAxis:  {
     type: 'category',
     boundaryGap: false,
     data: ['00:00', '01:15', '02:30', '03:45', '05:00', '06:15', '07:30', '08:45', '10:00', '11:15', '12:30', '13:45', '15:00', '16:15', '17:30', '18:45', '20:00', '21:15', '22:30', '23:45']
   },
   yAxis: {
     type: 'value',
     axisLabel: {
       formatter: '{value} W'
     }
   },
   visualMap: {
     show: false,
     dimension: 0,
     pieces: [{
       lte: 6,
       color: 'green'
     }, {
       gt: 6,
       lte: 8,
       color: 'red'
     }, {
       gt: 8,
       lte: 14,
       color: 'green'
     }, {
       gt: 14,
       lte: 17,
       color: 'red'
     }, {
       gt: 17,
       color: 'green'
     }]
   },
   series: [
     {
       name:'用电量',
       type:'line',
       smooth: true,
       data: [300, 280, 250, 260, 270, 300, 550, 500, 400, 390, 380, 390, 400, 500, 600, 750, 800, 700, 600, 400],
       markArea: {
         data: [ [{
           name: '早高峰',
           xAxis: '07:30'
         }, {
           xAxis: '10:00'
         }], [{
           name: '晚高峰',
           xAxis: '17:30'
         }, {
           xAxis: '21:15'
         }] ]
       }
     }
   ]
 };

  $scope.chartOpt3 = {
    tooltip: {
      trigger: 'axis'
    },
    toolbox: {
      feature: {
        dataView: {show: true, readOnly: false},
        magicType: {show: true, type: ['line', 'bar']},
        restore: {show: true},
        saveAsImage: {show: true}
      }
    },
    legend: {
      data:['蒸发量','降水量','平均温度']
    },
    xAxis: [
      {
        type: 'category',
        data: ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月']
      }
    ],
    yAxis: [
      {
        type: 'value',
        name: '水量',
        min: 0,
        max: 250,
        interval: 50,
        axisLabel: {
          formatter: '{value} ml'
        }
      },
      {
        type: 'value',
        name: '温度',
        min: 0,
        max: 25,
        interval: 5,
        axisLabel: {
          formatter: '{value} °C'
        }
      }
    ],
    series: [
      {
        name:'蒸发量',
        type:'bar',
        data:[2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3]
      },
      {
        name:'降水量',
        type:'bar',
        data:[2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3]
      },
      {
        name:'平均温度',
        type:'line',
        yAxisIndex: 1,
        data:[2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2]
      }
    ]
  };

}])
